// import { PET_STATE_LIST, IS_SHOW_HOME_LIST } from '@/const/type'
import { cardid } from '@/util/validate';
export const tableOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 260,
    labelWidth: 120,
    emptyBtn: false,
    submitBtn: false,
    group: [
      {
        label: '宠物信息',
        prop: 'group2',
        column: [
          {
            label: '宠物编号',
            prop: 'code',
            detail: true,
          },
          {
            label: '宠物昵称',
            prop: 'nickName',
            detail: true,
          },
          {
            label: '宠物性别',
            detail: true,
            prop: 'gender',
            type: 'select',
            dicUrl: '/admin/dict/type/pet_sex',
          },
          {
            label: '所属爱心收容站',
            prop: 'baseId',
            dicUrl: '/core/base/list',
            type: 'select',
            props: {
              label: 'name',
              value: 'id',
            },
            detail: true,
          },
          {
            label: '收容站位置',
            prop: 'baseAddress',
            detail: true,
          },
        ],
      },
      {
        label: '领养信息',
        prop: 'group1',
        labelWidth: 130,
        column: [
          {
            label: '领养人手机号',
            remote: true,
            prop: 'phone',
            type: 'select',
            filterable: true,
            clearable: true,
            dicUrl: `/app/appuser/list/?phone={{key}}`,
            props: {
              label: 'phone',
              value: 'phone',
            },
            // dicFormatter: (data) => {
            //   const res = data.data;
            //   res.forEach((el) => {
            //     const obj = {
            //       phone: el.phone,
            //       userNickName: el.nickname,
            //       userId: el.userId,
            //     };
            //     el.value = JSON.stringify(obj);
            //   });
            //   return res;
            // },
            rules: [
              {
                required: true,
                message: '请选择领养人手机号',
              },
            ],
          },
          {
            label: '领养人姓名',
            prop: 'adoptName',
            disabled: true,
            rules: [
              {
                required: true,
                message: '请输入领养人姓名',
              },
              {
                min: 1,
                max: 20,
                message: '长度不能超过20个字符',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '领养人身份证号',
            prop: 'adoptCard',
            disabled: true,
            rules: [
              {
                required: true,
                message: '请输入领养人身份证号',
              },
              {
                validator: (rule, value, callback) => {
                  if (cardid(value)[0]) {
                    callback(new Error(cardid(value)[1]));
                  } else {
                    callback();
                  }
                },
                trigger: 'blur',
              },
            ],
          },
          {
            label: '家庭住址',
            prop: 'adoptAddress',
            rules: [
              {
                required: true,
                message: '请输入家庭住址',
              },
              {
                min: 1,
                max: 50,
                message: '长度不能超过50个字符',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '用户编号',
            prop: 'userId',
            disabled: true,
            placeholder: '根据手机号码自动带出',
          },
          {
            label: '用户昵称',
            prop: 'userNickName',
            disabled: true,
            placeholder: '根据手机号码自动带出',
          },
          // {
          //   label: '领养日期',
          //   prop: 'adoptDate',
          //   type: 'date',
          //   format: 'yyyy-MM-dd',
          //   valueFormat: 'yyyy-MM-dd',
          //   rules: [
          //     {
          //       required: true,
          //       message: '请选择领养日期',
          //     },
          //   ],
          // },
          // {
          //   label: '签约日期',
          //   prop: 'signDate',
          //   type: 'date',
          //   format: 'yyyy-MM-dd',
          //   valueFormat: 'yyyy-MM-dd',
          //   rules: [
          //     {
          //       required: true,
          //       message: '请选择签约日期',
          //     },
          //   ],
          // },
        ],
      },
    ],
  };
};
